<%--
  Created by IntelliJ IDEA.
  User: 懒瑶瑶
  Date: 2022/5/22
  Time: 14:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>更多资料</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script>
        layui.use(['table','util','jquery','layer','form'],function () {
            var table = layui.table, util = layui.util, $ = layui.jquery, layer = layui.layer, form = layui.form;
            //查看工作经历
            var tabBoss = table.render({
                elem:'#tableData',//指定id选择器
                cols:[[
                    {field:'companyName',title:'公司名称'},
                    {field:'degree',title:'岗位'},
                    {field:'startDate',title:'入职时间',templet:function(d){
                            return util.toDateString(d.startDate,'yyyy年MM月dd日'
                            )}},
                    {field:'endDate',title:'离职时间',templet:function(c){
                return util.toDateString(c.endDate,'yyyy年MM月dd日'
                )}},
                    {field:'reason',title:'离职原因 '},
                    {field:'remark',title:'说明 '},
                    {toolbar:'#tools',title:'操作',width:150,align:'center',fixed:'right'}
                ]],
                url:'${pageContext.request.contextPath}/emp/emptolist/'+${empId},//请求路径
                method:'post',//请求方法
                loading:true,//数据加载效果样式
            });

            //监听添加按钮
            $("#add-btn").click(function () {
                layer.open({
                    type:2,
                    fix:false,
                    maxmin:true,
                    offset:'5px',
                    shadeClose:true,
                    shade:0.4,
                    area:['600px','520px'],
                    title:["新增工作经历",'font-size:18px; color:orange;'],
                    content:'${pageContext.request.contextPath}/emp/toaddjob/'+${empId},
                });
            });
            //监听工具栏的按钮删除
            table.on('tool(tableData)',function (res) {
                var row = res.data; //获取当前数据（点哪一行就是哪一行）
                var event = res.event;//获取点的是哪个按钮
                // alert(event);
                var jobId = row.jobId;
                if(event=='look'){
                    //把id传到后台去删除
                    // alert(row.empId); 弹出要删除的ID
                    layer.confirm('是否删除该工作经历？',{
                        btn:['确定','取消']
                    },function () {//确定的回调函数
                        // alert(row.empId);测试是否进入
                        $.post("${pageContext.request.contextPath}/emp/deljob",{jobId:jobId},function (data) {
                            layer.msg(data.msg);  //使用消息层 显示删除结果
                            //重新加载table
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name);
                                location.reload();//重新加载父页面表格
                            }, 2100);
                        },"json");
                    });
                }
            });
            //查看教育背景-----------------------------------------------------------------------------------------------------------
            var tabBoss2 = table.render({
                elem:'#tableData2',//指定id选择器
                cols:[[
                    {field:'collegeName',title:'学校名称'},
                    {field:'degree',title:'学历'},
                    {field:'startDate',title:'入校时间',templet:function(d){
                            return util.toDateString(d.startDate,'yyyy年MM月dd日'
                            )}},
                    {field:'endDate',title:'毕业时间',templet:function(c){
                            return util.toDateString(c.endDate,'yyyy年MM月dd日'
                            )}},
                    {field:'remark',title:'奖惩情况'},
                    {toolbar:'#tools2',title:'操作',width:150,align:'center',fixed:'right'}
                ]],
                url:'${pageContext.request.contextPath}/emp/emptolist2/'+${empId},//请求路径
                method:'post',//请求方法
                loading:true,//数据加载效果样式
            });

            //监听添加按钮
            $("#add-btn2").click(function () {
                layer.open({
                    type:2,
                    fix:false,
                    maxmin:true,
                    offset:'5px',
                    shadeClose:true,
                    shade:0.4,
                    area:['600px','520px'],
                    title:["新增教育背景",'font-size:18px; color:orange;'],
                    content:'${pageContext.request.contextPath}/emp/toaddedu/'+${empId},
                });
            });

            //监听工具栏的按钮删除
            table.on('tool(tableData2)',function (res) {
                var row = res.data; //获取当前数据（点哪一行就是哪一行）
                var event = res.event;//获取点的是哪个按钮
                // alert(event);
                var collegeId = row.collegeId;
                if(event=='look2'){
                    //把id传到后台去删除
                    // alert(row.empId); 弹出要删除的ID
                    layer.confirm('是否删除该教育背景？',{
                        btn:['确定','取消']
                    },function () {//确定的回调函数
                        // alert(row.collegeId);//测试是否进入
                        $.post("${pageContext.request.contextPath}/emp/deledu",{collegeId:collegeId},function (data) {
                            // alert("ll");//测试是否进入
                            layer.msg(data.msg);  //使用消息层 显示删除结果
                            //重新加载table
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name);
                                location.reload();//重新加载父页面表格
                            }, 2100);
                        },"json");
                    });
                }
            });
            //查看家庭联系关系--------------------------------------------------------------------------------------
            var tabBoss3 = table.render({
                elem:'#tableData3',//指定id选择器
                cols:[[
                    {field:'contactName',title:'联系人名称'},
                    {field:'relationship',title:'与员工关系'},
                    {field:'phone',title:'联系电话'},
                    {field:'remark',title:'说明'},
                    {toolbar:'#tools3',title:'操作',width:150,align:'center',fixed:'right'}
                ]],
                url:'${pageContext.request.contextPath}/emp/emptolist3/'+${empId},//请求路径
                method:'post',//请求方法
                loading:true,//数据加载效果样式
            });
            //监听添加按钮
            $("#add-btn3").click(function () {
                layer.open({
                    type:2,
                    fix:false,
                    maxmin:true,
                    offset:'5px',
                    shadeClose:true,
                    shade:0.4,
                    area:['600px','520px'],
                    title:["新增家庭联系关系",'font-size:18px; color:orange;'],
                    content:'${pageContext.request.contextPath}/emp/toaddfamily/'+${empId},
                });
            });
            //监听工具栏的按钮删除
            table.on('tool(tableData3)',function (res) {
                var row = res.data; //获取当前数据（点哪一行就是哪一行）
                var event = res.event;//获取点的是哪个按钮
                // alert(event);
                var familyId = row.familyId;
                if(event=='look3'){
                    //把id传到后台去删除
                    // alert(row.empId); 弹出要删除的ID
                    layer.confirm('是否删除该联系？',{
                        btn:['确定','取消']
                    },function () {//确定的回调函数
                        // alert(row.collegeId);//测试是否进入
                        $.post("${pageContext.request.contextPath}/emp/delfamily",{familyId:familyId},function (data) {
                            // alert("ll");//测试是否进入
                            layer.msg(data.msg);  //使用消息层 显示删除结果
                            //重新加载table
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name);
                                location.reload();//重新加载父页面表格
                            }, 2100);
                        },"json");
                    });
                }
            });
            //查看员工考核--------------------------------------------------------------------------------------
            var tabBoss4 = table.render({
                elem:'#tableData4',//指定id选择器
                cols:[[
                    {field:'aduitName',title:'考核指标'},
                    {field:'scores',title:'考核分数'},
                    {field:'image',title:'图片',templet:function (d) {
                            var zid=d.image;//取出每一个数据
                            if(zid==""||zid==null){
                                return '未上传图片'
                            }else if(zid!=""){
                                return '已上传图片'
                            }
                        }},
                    {field:'remark',title:'说明'},
                    {field:'auditPerson',title:'入录人员'},
                    {toolbar:'#tools4',title:'操作',align:'center',fixed:'right'}
                ]],
                url:'${pageContext.request.contextPath}/emp/emptolist4/'+${empId},//请求路径
                method:'post',//请求方法
                loading:true,//数据加载效果样式
            });

            //监听添加按钮
            $("#add-btn4").click(function () {
                layer.open({
                    type:2,
                    fix:false,
                    maxmin:true,
                    offset:'5px',
                    shadeClose:true,
                    shade:0.4,
                    area:['600px','520px'],
                    title:["新增员工考核",'font-size:18px; color:orange;'],
                    content:'${pageContext.request.contextPath}/emp/toaddlog/'+${empId},
                });
            });
            //监听工具栏的按钮删除
            table.on('tool(tableData4)',function (res) {
                var row = res.data; //获取当前数据（点哪一行就是哪一行）
                var event = res.event;//获取点的是哪个按钮
                // alert(event);
                var aduitLogId = row.aduitLogId;
                if(event=='look4'){
                    //把id传到后台去删除
                    // alert(row.empId); 弹出要删除的ID
                    layer.confirm('是否删除考核？',{
                        btn:['确定','取消']
                    },function () {//确定的回调函数
                        // alert(row.collegeId);//测试是否进入
                        $.post("${pageContext.request.contextPath}/emp/dellog",{aduitLogId:aduitLogId},function (data) {
                            // alert("ll");//测试是否进入
                            layer.msg(data.msg);  //使用消息层 显示删除结果
                            //重新加载table
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name);
                                location.reload();//重新加载父页面表格
                            }, 2100);
                        },"json");
                    });
                }else if(event=='look5'){//如果是查看
                    layer.open({
                        type:2,
                        fix:false,
                        maxmin:true,
                        offset:'10px',
                        shadeClose:true,
                        shade:0.4,
                        area:['1000px','500px'],
                        title:["员工考核详情",'font-size:18px; color:orange;'],
                        content:'${pageContext.request.contextPath}/emp/tolooklog/'+aduitLogId
                    });
                }
            });
            //查看员工证件--------------------------------------------------------------------------------------
            var tabBoss5 = table.render({
                elem:'#tableData5',//指定id选择器
                cols:[[
                    {field:'empName',title:'员工名称'},
                    {field:'imgName',title:'证件名称'},
                    {field:'papers',title:'证件',templet:function (d) {
                            var zid=d.papers;//取出每一个数据
                            if(zid==""||zid==null){
                                return '未上传证件'
                            }else if(zid!=""){
                                return '已上传证件'
                            }
                        }},

                    {field:'uploadtime',title:'上传时间',templet:function(c){
                            return util.toDateString(c.uploadtime,'yyyy年MM月dd日'
                            )}},
                    {field:'auditPerson',title:'上传人员'},
                    {field:'remark',title:'备注'},
                    {toolbar:'#tools5',title:'操作',align:'center',fixed:'right'}
                ]],
                url:'${pageContext.request.contextPath}/emp/emptolist5/'+${empId},//请求路径
                method:'post',//请求方法
                loading:true,//数据加载效果样式
            });

            //监听添加按钮
            $("#add-btn5").click(function () {
                layer.open({
                    type:2,
                    fix:false,
                    maxmin:true,
                    offset:'5px',
                    shadeClose:true,
                    shade:0.4,
                    area:['600px','520px'],
                    title:["新增员工证件",'font-size:18px; color:orange;'],
                    content:'${pageContext.request.contextPath}/emp/toaddpaper/'+${empId},
                });
            });
            //监听工具栏的按钮删除
            table.on('tool(tableData5)',function (res) {
                var row = res.data; //获取当前数据（点哪一行就是哪一行）
                var event = res.event;//获取点的是哪个按钮
                // alert(event);
                var imgId = row.imgId;
                if(event=='look7'){
                    //把id传到后台去删除
                    // alert(row.imgId); //弹出要删除的ID
                    layer.confirm('是否删除证件？',{
                        btn:['确定','取消']
                    },function () {//确定的回调函数
                        // alert("确认"+row.imgId);//测试是否进入
                        $.post("${pageContext.request.contextPath}/emp/delpaper",{imgId:imgId},function (data) {
                            // alert("ll");//测试是否进入
                            layer.msg(data.msg);  //使用消息层 显示删除结果
                            //重新加载table
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name);
                                location.reload();//重新加载父页面表格
                            }, 2100);
                        },"json");
                    });
                }else if(event=='look6'){//如果是查看
                    layer.open({
                        type:2,
                        fix:false,
                        maxmin:true,
                        offset:'10px',
                        shadeClose:true,
                        shade:0.4,
                        area:['1000px','500px'],
                        title:["员工证件详情",'font-size:18px; color:orange;'],
                        content:'${pageContext.request.contextPath}/emp/tolookpaper/'+imgId
                    });
                }
            });
        });
    </script>
</head>
<body>
<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        <li class="layui-this">工作经历</li>
        <li>教育背景</li>
        <li>家庭联系信息</li>
        <li>员工考核</li>
        <li>证件上传</li>
    </ul>
    <div class="layui-tab-content" style="height: 300px;">
    <%--工作经历--%>
        <div class="layui-tab-item layui-show">
            <a class="layui-btn layui-icon layui-icon-add-1" id="add-btn"  lay-size="sm">新增</a>
            <table  class="layui-table" id="tableData" lay-filter="tableData" lay-size="sm"></table>
            <%--    定义工具栏--%>
            <script type="text/html" id="tools">
                <a class="layui-btn  layui-btn-sm layui-btn-danger" lay-event="look">删除</a>
            </script>
        </div>
    <%--教育背景--%>
        <div class="layui-tab-item">
            <a class="layui-btn layui-icon layui-icon-add-1" id="add-btn2"  lay-size="sm">新增</a>
            <table  class="layui-table" id="tableData2" lay-filter="tableData2" lay-size="sm"></table>
            <%--    定义工具栏--%>
            <script type="text/html" id="tools2">
                <a class="layui-btn  layui-btn-sm layui-btn-danger" lay-event="look2">删除</a>
            </script>
        </div>
    <%--家庭联系信息--%>
        <div class="layui-tab-item">
            <a class="layui-btn layui-icon layui-icon-add-1" id="add-btn3"  lay-size="sm">新增</a>
            <table  class="layui-table" id="tableData3" lay-filter="tableData3" lay-size="sm"></table>
            <%--    定义工具栏--%>
            <script type="text/html" id="tools3">
                <a class="layui-btn  layui-btn-sm layui-btn-danger" lay-event="look3">删除</a>
            </script>
        </div>
    <%--员工考核--%>
        <div class="layui-tab-item">
            <a class="layui-btn layui-icon layui-icon-add-1" id="add-btn4"  lay-size="sm">新增</a>
            <table  class="layui-table" id="tableData4" lay-filter="tableData4" lay-size="sm"></table>
            <%--    定义工具栏--%>
            <script type="text/html" id="tools4">
                <a class="layui-btn  layui-btn-sm" lay-event="look5">查看详情</a>
                <a class="layui-btn  layui-btn-sm layui-btn-danger" lay-event="look4">删除</a>
            </script>

        </div>
<%--        员工证件--%>
        <div class="layui-tab-item">
            <a class="layui-btn layui-icon layui-icon-add-1" id="add-btn5"  lay-size="sm">新增</a>
            <table  class="layui-table" id="tableData5" lay-filter="tableData5" lay-size="sm"></table>
            <%--    定义工具栏--%>
            <script type="text/html" id="tools5">
                <a class="layui-btn  layui-btn-sm" lay-event="look6">查看详情</a>
                <a class="layui-btn  layui-btn-sm layui-btn-danger" lay-event="look7">删除</a>
            </script>

        </div>
    </div>
</div>
</body>
</html>
